package pres.man.interview.thread;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 线程池状态
 *
 * @author MAN
 * @date 2020-12-07-17:51
 */
public class ThreadPoolState {
    public static void main(String[] args) {
        ThreadPoolExecutor POOL = new DefaultThreadPoolExecutor(5, 8, 20, TimeUnit.SECONDS, new ArrayBlockingQueue<>(10), new ThreadPoolExecutor.CallerRunsPolicy());

        POOL.execute(() -> System.out.println("1"));
        POOL.execute(() -> System.out.println("2"));
        POOL.execute(() -> {
            try {
                TimeUnit.SECONDS.sleep(5);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("3");
        });


        POOL.shutdownNow();
    }
}
